import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by xwj on 2017/9/1.
 */
public class Prediction {
//分析出每一个对应的segment 并合成为一个文件；

    private static int frameRate = 25;
    private static int segTime = 1;

    public static List<Point> getPredictPoint(List<Point> pointList) {
        List<Point> returnList = new ArrayList();
        for (int i = 0; i < pointList.size(); i += (frameRate * segTime))
            returnList.add(pointList.get(i));
        return returnList;
    }

    public static Point predictPointByPreviousInfo(Point last, Point now, double xfactor, double yfactor) {
        Point p = new Point(0, 0);
        p.setX(Util.clip(now.getX() + (now.getX() - last.getX()) * xfactor));
        p.setY(Util.clip(now.getY() + (now.getY() - last.getY()) * yfactor));
        return p;
    }

    public static String getBlockByPoint(Point point) {
        double block = 0.25;
        int horizon = 0, vertical = 0;

        if (point.getX() <= block * 0.25 || point.getX() >= block * 3.75)
            horizon = 1;
        else if (point.getX() >= block * 0.25 && point.getX() < block * 0.75)
            horizon = 2;
        else if (point.getX() >= block * 0.75 && point.getX() < block * 1.25)
            horizon = 3;
        else if (point.getX() >= block * 1.25 && point.getX() < block * 1.75)
            horizon = 4;
        else if (point.getX() >= block * 1.75 && point.getX() < block * 2.25)
            horizon = 5;
        else if (point.getX() >= block * 2.25 && point.getX() < block * 2.75)
            horizon = 6;
        else if (point.getX() >= block * 2.75 && point.getX() < block * 3.25)
            horizon = 7;
        else if (point.getX() >= block * 3.25 && point.getX() < block * 3.75)
            horizon = 8;

    /*
        block=1/3;
        if(point.getY()<0.5+block*0.25){

        }
    */
        return horizon + "-" + vertical;

    }


}
